/**
* Created by QiYuBu on 2016/11/26.
* @ Description:[头部]
*/
<template>
  <div class="headNav fix home-head ">
   <!-- <div class="homeimg" @click.prevent ="myClick(myAddress)">
      <i class="icon iconfont icon-my2line"></i>
      <img class="icon" src="../assets/images/people.png">
    </div>-->
    <div class="centerTitle" v-text="centerTitle">

    </div>
    <div class="reghtTitle" @click="reght_click">{{rightTitle}}</div>
  </div>
</template>
<style lang="scss" rel="stylesheet/scss" scoped>

  .homeimg{
    position: absolute;
    left:.75rem;
    top:.25rem;
    width: 1.7rem;
    height: 1.7rem;
    background-color: #FFFFFF;
    border-radius: .85rem;
    z-index:99;}
   .homeimg .icon{
      font-size: 1rem;
      color: #0c80ba;
     width: 1.65rem;
     height: 1.65rem;
      position: absolute;
      top: 0px;
      left: 0px;
    }
   .reghtTitle{
     font-size: .7rem;/*px*/
     color: #FFFFFF;
     position: absolute;
     top:0;
     right: .5rem;
     line-height: 2.2rem;
     z-index: 100;
   }
  .headNav {
    z-index: 99;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    background: rgba(70, 161, 187, 1);
    background-size: cover;
    height: 2.2rem;
    padding: 0 .75rem;
  }
  .centerTitle{
    font-size: .8rem;
    color: #FFFFFF;
    line-height: 2.2rem;
    text-align: center;
  }
</style>
<script>
  import {Cell,Indicator} from 'mint-ui';
  export default{
    props: ['centerTitle', 'rightTitle'],

    data(){
      return {
      }
    },
    methods: {
      myClick(callback){
        let mypath = this.$route.name;
        if(mypath==='mypage'){
          return;
        }
        this.$router.push({
          name: "mypage"
        });
        //定义从那个页面进入的;
        this.$store.state.headNav.back = mypath;
        //执行加载动画
        var that = this;
        that.axios.get('members/personalInfo/or.json').then(function (res) {
          that.$store.state.myPersonalInfo = res.data;
          callback();
        });
      },
      myAddress(){
        //地址信息  获取默认地址
        var that =this;
        var serverUrl = $tool.getServerUrl();
        app.ajax({
          type: 'get',
          url: serverUrl+'/members/address/list.json',
          data: {
            isDefault:1 //获取默认地址
          },
          dataType:'jsonp',
          jsonp:'callback',
        }).done(function (res) {
          Indicator.close();
//          console.log('请求默认地址成功');
//          console.log(res);
          if(res.defaultAddressesDtoPage.list.length == 0){ //用户刚进来 地址列表是空的
            var list = [{country:'', province:'', city:'',}];
            that.$store.state.myAddressInfo.defaultAddressesDtoPage.list = list;
          }else{
            that.$store.state.myAddressInfo = res;
          }
        }).fail(function (res) {
          Indicator.close();
        });
      },
      reght_click(){
        this.$emit('reght_click')
      }
    }

  }
</script>
